import { Application } from "egg";

/**
 * @param {Application} app - egg application
 */
export default (app: Application) => {
  const { router, controller } = app;

  // 健康检查
  router.get("/api/health", controller.home.health);

  // 认证相关路由
  router.post("/api/auth/register", controller.auth.register);
  router.post("/api/auth/login", controller.auth.login);
  router.get("/api/auth/profile", controller.auth.profile);
  router.put("/api/auth/profile", controller.auth.updateProfile);
  // 钱包相关 - 需要 JWT 认证
  router.post("/api/auth/wallet-nonce", app.jwt, controller.auth.walletNonce);
  router.post("/api/auth/verify-wallet", app.jwt, controller.auth.verifyWallet);

  // 项目相关路由
  router.get("/api/projects", controller.project.list);
  router.get("/api/projects/:id", controller.project.detail);
  router.post("/api/projects", controller.project.create);
  router.put("/api/projects/:id", controller.project.update);
  router.delete("/api/projects/:id", controller.project.delete);
  router.post("/api/projects/:id/approve", controller.project.approve);
  router.post("/api/projects/:id/reject", controller.project.reject);

  // 捐款相关路由
  // router.post('/donations', controller.donation.create);
  // router.get('/donations', controller.donation.list);
  // router.get('/donations/:id', controller.donation.detail);
  // router.get('/projects/:id/donations', controller.donation.listByProject);

  // 项目进展相关路由
  // router.get('/projects/:id/updates', controller.projectUpdate.list);
  // router.post('/projects/:id/updates', controller.projectUpdate.create);
  // router.put('/updates/:id', controller.projectUpdate.update);
  // router.delete('/updates/:id', controller.projectUpdate.delete);

  // 数据统计路由
  // router.get('/stats/overview', controller.stats.overview);
  // router.get('/stats/projects', controller.stats.projects);
  // router.get('/stats/donations', controller.stats.donations);

  // 文件上传路由
  // router.post('/upload/image', controller.upload.image);
  // router.post('/upload/document', controller.upload.document);
};
